package com.diver.flinkdemo.utils;

import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

/**
 * 时间工具类
 */
public class DateUtil {


    /**
     * 获取今日时间 年月日时分秒
     *
     * @return
     */
    public static String getCurrentTime() {
        return getNowDateWholePoint("yyyy-MM-dd HH:mm:ss");
    }

    /**
     * 获取前几个月的时间
     *
     * @return
     */
    public static String getPastTime(int month) {
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.MONTH, month);
        return sd.format(c.getTime());
    }

    /**
     * 获取明天 08.00.00点时间
     *
     * @return
     */
    public static String getTomorrowTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 08:00:00");
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, +1);// 明天的日期
        return sdf.format(cal.getTime());
    }

    /**
     * 获取7天后时间
     *
     * @return
     */
    public static String getNextSevenDay() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, +7);// 明天的日期
        return sdf.format(cal.getTime());
    }

    /**
     * 比较日期格式大小
     *
     * @param time1 时间1
     * @param time2 时间2
     * @return 如果start》end 则返回 1  start=end 则返回0  start < end 则为 -1
     */
    public static int compareTo(Date time1, Date time2) {
        int compareTo = -1;
        try {

            compareTo = time1.compareTo(time2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return compareTo;
    }

    /**
     * 计算指定日期之前或者之后的多少分钟
     *
     * @param date
     * @param minute
     * @return
     */
    public static String getTimeByMinute(Date date, int minute) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.MINUTE, minute);
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());

    }

    /**
     * 比较两个时间 时分秒 大小
     *
     * @param s1
     * @param s2
     * @return
     */
    public static boolean compTime(String s1, String s2) {
        try {
            if (s1.indexOf(":") < 0 || s1.indexOf(":") < 0) {
                System.out.println("格式不正确");
            } else {
                String[] array1 = s1.split(":");
                int total1 = Integer.valueOf(array1[0]) * 3600 + Integer.valueOf(array1[1]) * 60 + Integer.valueOf(array1[2]);
                String[] array2 = s2.split(":");
                int total2 = Integer.valueOf(array2[0]) * 3600 + Integer.valueOf(array2[1]) * 60 + Integer.valueOf(array2[2]);
                return total1 - total2 > 0 ? true : false;
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
            // TODO Auto-generated catch block
        }
        return false;

    }

    /**
     * 判断是否是同一天
     *
     * @param date1
     * @param date2
     * @return
     */
    public static boolean isSameDate(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);

        boolean isSameYear = cal1.get(Calendar.YEAR) == cal2
                .get(Calendar.YEAR);
        boolean isSameMonth = isSameYear
                && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
        boolean isSameDate = isSameMonth
                && cal1.get(Calendar.DAY_OF_MONTH) == cal2
                .get(Calendar.DAY_OF_MONTH);

        return isSameDate;
    }

    /**
     * 判断是否是今日
     *
     * @param data
     * @return
     */
    public static boolean JudgeIsToday(String data) {
        long dateLong = dateToStamp(data);
        if (dateLong >= getTodayStart() && dateLong <= getTodayEnd()) {
            return true;
        }
        return false;
    }

    /**
     * 获取今天00:00:00 时间搓
     *
     * @return
     */
    public static long getTodayStart() {
        Calendar calendar = new GregorianCalendar();
        calendar.add(Calendar.DAY_OF_MONTH, 0);
        //一天的开始时间 yyyy:MM:dd 00:00:00
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date dayStart = calendar.getTime();
        return dayStart.getTime();
    }

    /**
     * 获取今天23:59:59 时间搓
     *
     * @return
     */
    public static long getTodayEnd() {
        Calendar calendar = new GregorianCalendar();
        //一天的结束时间 yyyy:MM:dd 23:59:59
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        Date dayEnd = calendar.getTime();
        return dayEnd.getTime();
    }

    /*
     * 将时间转换为时间戳
     */
    public static long dateToStamp(String s) {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        try {
            date = simpleDateFormat.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long ts = date.getTime();
//        res = String.valueOf(ts);
        return ts;
//        return (int) ts;
    }

    /**
     * 获取上周日 00.00.00点时间
     *
     * @return
     */
    public static String lastFirday() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        Calendar cal = Calendar.getInstance();
        int n = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (n == 0) {
            n = 7;
        }
//        cal.add(Calendar.DATE, -(7 + (n - 1)));// 上周一的日期
        cal.add(Calendar.DATE, -(1 + (n - 1)));// 上周天的日期
        String weekEnd = sdf.format(cal.getTime());
        return weekEnd;
    }

    /**
     * 获取上周六 23.59.59点时间
     *
     * @return
     */
    public static String lastSaturday() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
        Calendar cal = Calendar.getInstance();
        int n = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (n == 0) {
            n = 7;
        }
//        cal.add(Calendar.DATE, -(7 + (n - 1)));// 上周一的日期
        cal.add(Calendar.DATE, -(2 + (n - 1)));// 上周天的日期
        String weekEnd = sdf.format(cal.getTime());
        return weekEnd;
    }

    public static String getlasFirdayBydata(String time) {
        Calendar cal = Calendar.getInstance();
        try {
            cal.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(time));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        int n = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (n == 0) {
            n = 7;
        }
//        cal.add(Calendar.DATE, -(7 + (n - 1)));// 上周一的日期
        cal.add(Calendar.DATE, -(1 + (n - 1)));// 上周天的日期
        String weekEnd = sdf.format(cal.getTime());
        return weekEnd;
    }

    /**
     * Date转LocalDate
     *
     * @param date
     */
    public static LocalDate date2LocalDate(Date date) {
        if (null == date) {
            return null;
        }
        return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    }

//    /**
//     * 当前时间所在一周的周日时间
//     * @return
//     */
//    public static String getSundayData() {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
//
//        Calendar cal = Calendar.getInstance();
//        cal.setFirstDayOfWeek(Calendar.MONDAY);// 设置一个星期的第一天，按中国的习惯一个星期的第一天是星期一
//        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
//        if(dayWeek==1){
//            dayWeek = 8;
//        }
//        System.out.println("要计算日期为:" + sdf.format(cal.getTime())); // 输出要计算日期
//        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - dayWeek);// 根据日历的规则，给当前日期减去星期几与一个星期第一天的差值
////        Date mondayDate = cal.getTime();
////        String weekBegin = sdf.format(mondayDate);
////        System.out.println("所在周星期一的日期：" + weekBegin);
//        cal.add(Calendar.DATE, 4 +cal.getFirstDayOfWeek());
//        Date sundayDate = cal.getTime();
//        String weekEnd = sdf.format(sundayDate);
//        System.out.println("所在周星期日的日期：" + weekEnd);
//
//        return weekEnd;
//    }


    public static Date parseDate(String dateString, String pattern) throws ParseException {
        DateFormat dateFormat = new SimpleDateFormat(pattern);
        Date date = dateFormat.parse(dateString);
        return date;
    }

    public static String format(Date date, String pattern) {
        DateFormat dateFormat = new SimpleDateFormat(pattern);
        return dateFormat.format(date);
    }

    public static String getNowDate(String pattern) {
        // 线程安全的格式化类，不用每次都new个SimpleDateFormat
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }


    /**
     * 按照格式 获取今日时间
     *
     * @return
     */
    public static String getNowDateWholePoint(String pattern) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }


    /**
     * 获取今日 日期 yyyy-MM-dd
     *
     * @return
     */
    public static String getTodayDate() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }

    /**
     * 按照格式 获取昨日时间
     *
     * @return
     */
    public static String getYesterdayWholePoint(String pattern) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        Date d = cal.getTime();
        SimpleDateFormat sp = new SimpleDateFormat(pattern);
        return sp.format(d);//获取昨天日期
    }

    /**
     * 获取昨日 日期 yyyy-MM-dd
     *
     * @return
     */
    public static String getYesterdayDate() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        Date d = cal.getTime();
        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
        return sp.format(d);//获取昨天日期
    }

    /**
     * 获取当前时间 时针时间
     *
     * @return
     */
    public static String getNowDateHourHand() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH");
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }

    /**
     * 字符串转日期
     *
     * @param dateTime
     * @param pattern
     * @return
     */
    public static LocalDateTime parseDateTime(String dateTime, String pattern) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        return LocalDateTime.parse(dateTime, dateTimeFormatter);
    }


    public static String transformationByTime(LocalDateTime localDateTime) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
        return dateTimeFormatter.format(localDateTime);
    }


    /**
     * 获取年份
     *
     * @return
     */
    public static int getYear() {
        /*Year year = Year.now();
        return Integer.parseInt(year.toString());*/
        return LocalDate.now().getYear();
    }

    /**
     * 获取月份
     *
     * @return
     */
    public static int getMonth() {
       /* Calendar calendar=Calendar.getInstance();
        int month=calendar.get(Calendar.MONTH)+1; //获得当前时间的月份，月份从0开始所以结果要加1
        return month;*/
        Month month = LocalDate.now().getMonth();
        return month.getValue();

    }

    /**
     * 获取第几号
     *
     * @return
     */
    public static int getDay() {
       /* Calendar calendar=Calendar.getInstance();
        //获得当前时间的月份，月份从0开始所以结果要加1
        int day=calendar.get(Calendar.DAY_OF_MONTH);
        return day;*/
        return LocalDate.now().getDayOfMonth();
    }

    /**
     * 字符串转data
     *
     * @param dateStr
     * @param pattern
     * @return
     */
    public static Date getDate(String dateStr, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            return sdf.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Date getDate(String dateStr) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            return sdf.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 星期
     *
     * @param localDate
     * @return
     */
    public static String getWeekOfDate(LocalDate localDate) {
        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
        DayOfWeek dayOfWeek = localDate.getDayOfWeek();
        int w = dayOfWeek.getValue();
        if (w < 0 || w >= 7)
            w = 0;
        return weekDays[w];
    }

    public static int getDayOfWeek(LocalDate localDate) {
        return localDate.getDayOfWeek().getValue();
    }

    public static String dateToWeek(String datetime) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        String[] weekDays = {"星期日", "星期一", "星期二", "星期三",
                "星期四", "星期五", "星期六"};
        Calendar cal = Calendar.getInstance(); // 获得一个日历
        Date datet = null;
        try {
            datet = f.parse(datetime);
            cal.setTime(datet);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 指示一个星期中的某天。
        if (w < 0)
            w = 0;
        return weekDays[w];
    }

    /**
     * 判断是否是闰年
     *
     * @param year
     * @return
     */
    public static boolean isLeapYear(int year) {
        Year y = Year.of(year);
        return y.isLeap();
    }

    /**
     * 根据年份数，该年的月份数,该月的天数 返回日期
     *
     * @param year
     * @param month
     * @param days
     * @return
     */
    public static LocalDate getDate(int year, int month, int days) {
        Year y = Year.of(year);
        YearMonth yearMonth = y.atMonth(month);
        LocalDate localDate = yearMonth.atDay(days);
        return localDate;

    }

    /**
     * 如果某年是平年，但天数如果写的是29会自动转成28
     *
     * @param year
     * @param month
     * @param days
     * @return
     */
    public static LocalDate getDateAutoParse(int year, int month, int days) {
        MonthDay monthDay = MonthDay.of(month, days);
        return monthDay.atYear(year);
    }

    public static String getDateString(int year, int month, int day) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        MonthDay monthDay = MonthDay.of(month, day);
        LocalDate date = monthDay.atYear(year);
        return dateTimeFormatter.format(date);
    }

    public static String getDateTimeString(LocalDate localDate) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return dateTimeFormatter.format(localDate);
    }

    /**
     * 当前日期的下几个日期
     *
     * @param localDate
     * @return
     */
    public static String getNextDate(LocalDate localDate, int i, String pattern) {
        LocalDate nextDate = localDate.plusDays(i);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        return dateTimeFormatter.format(nextDate);

    }

    /**
     * 当前日期的下几个日期
     *
     * @param localDate
     * @param i
     * @return
     */
    public static LocalDate getNextDate(LocalDate localDate, int i) {
        LocalDate nextDate = localDate.plusDays(i);
        return nextDate;

    }

    /**
     * 今天的日期
     *
     * @param pattern
     * @return
     */
    public String getDateToDay(String pattern) {
        LocalDate today = LocalDate.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        return dateTimeFormatter.format(today);
    }

    /**
     * 计算两个日期之间天数
     *
     * @param date1
     * @param date2
     * @return
     */
    public static long caculateDays(LocalDate date1, LocalDate date2) {

        return ChronoUnit.DAYS.between(date1, date2);
    }

    /**
     * 计算两个日期之间的分钟数
     *
     * @param time1
     * @param time2
     * @return
     */
    public static long caculateMinutes(LocalDateTime time1, LocalDateTime time2) {
        return ChronoUnit.MINUTES.between(time1, time2);
    }

    /**
     * 计算两个日期之间的秒钟数
     *
     * @param time1
     * @param time2
     * @return
     */
    public static long caculateSeconds(LocalDateTime time1, LocalDateTime time2) {
        return ChronoUnit.SECONDS.between(time1, time2);
    }

    /**
     * 获取毫秒数
     *
     * @param localDateTime
     * @return
     */
    public static long getMill(LocalDateTime localDateTime) {
        return localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    /**
     * Date和LocalDateTime互转
     *
     * @param date
     * @return
     */
    public static LocalDateTime getFromDate(Date date) {
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        return LocalDateTime.ofInstant(instant, zoneId);
    }

    public static String formatDate(LocalDateTime time) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }

    public static String formatDate(LocalDateTime time, String pattern) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        return dateTimeFormatter.format(time);
    }

    public static Date getDateNow() {
        ZoneId zoneId = ZoneId.of("GMT+08");
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zdt = localDateTime.atZone(zoneId);

        Date date = Date.from(zdt.toInstant());
        return date;
    }

    /**
     * 设置指定日期时间
     *
     * @param year
     * @param month
     * @param day
     * @param hour
     * @param min
     * @param second
     * @return
     */
    public static LocalDateTime getLocalDateTime(int year, int month, int day, int hour, int min, int second) {
        LocalDateTime of = LocalDateTime.of(year, month, day, hour, min, second);
        return of;
    }

    //yyyy-MM-dd
    public static LocalDate getLocalDate(String date) {
        return LocalDate.parse(date);
    }

    public static int getHour() {
        return LocalDateTime.now().getHour();
    }

    //通过毫秒数返回日期时间
    public static String getDateTimeStringByMil(long millisecond) {
        Date date = new Date(millisecond);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

    //通过毫秒数返回日期
    public static String getDateStringByMil(long millisecond) {
        Date date = new Date(millisecond);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }

    public static long getMillisecond() {
        return new Date().getTime();
    }

    //获取毫秒数
    public static long getMillisecondByDateTimeString(String dateTime, String pattern) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.parse(dateTime).getTime();
    }

    public static Map<String, String> getTheStartEndOfDay() {
        Calendar calendar = new GregorianCalendar();
        calendar.add(Calendar.DAY_OF_MONTH, 0);
        //一天的开始时间 yyyy:MM:dd 00:00:00
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date dayStart = calendar.getTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startStr = simpleDateFormat.format(dayStart);

        //一天的结束时间 yyyy:MM:dd 23:59:59
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        Date dayEnd = calendar.getTime();
        String endStr = simpleDateFormat.format(dayEnd);
        Map<String, String> map = new HashMap<>();
        map.put("startTime", startStr);
        map.put("endTime", endStr);
        return map;
    }


    public static Map<String, String> getTheStartEndOfLastDay() {
        Calendar calendar = new GregorianCalendar();
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        //一天的开始时间 yyyy:MM:dd 00:00:00
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date dayStart = calendar.getTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startStr = simpleDateFormat.format(dayStart);

        //一天的结束时间 yyyy:MM:dd 23:59:59
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        Date dayEnd = calendar.getTime();
        String endStr = simpleDateFormat.format(dayEnd);
        Map<String, String> map = new HashMap<>();
        map.put("startTime", startStr);
        map.put("endTime", endStr);
        return map;
    }

    public static Boolean whetherTimeOverlaps(String leftTimeStr, String rightTimeStr) {
        if (!"".equals(leftTimeStr) && !"".equals(rightTimeStr)) {
            // 截取逗号前的字符串
            String leftStart = leftTimeStr.substring(0, leftTimeStr.indexOf("-"));
            // 截取逗号后的字符串
            String leftEnd = leftTimeStr.substring(leftStart.length() + 1, leftTimeStr.length());
            // 截取逗号前的字符串
            String rightStart = rightTimeStr.substring(0, rightTimeStr.indexOf("-"));
            // 截取逗号后的字符串
            String rightEnd = rightTimeStr.substring(leftStart.length() + 1, rightTimeStr.length());
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:ss");
            try {
                Date leftStartDate = simpleDateFormat.parse(leftStart);
                Date leftEndDate = simpleDateFormat.parse(leftEnd);
                Date rightStartDate = simpleDateFormat.parse(rightStart);
                Date rightEndDate = simpleDateFormat.parse(rightEnd);
                /*判断*/
                if (((leftStartDate.getTime() > rightStartDate.getTime())
                        && leftStartDate.getTime() < rightEndDate.getTime())
                        || ((leftStartDate.getTime() > rightStartDate.getTime())
                        && leftStartDate.getTime() < rightEndDate.getTime())
                        || ((rightStartDate.getTime() > leftStartDate.getTime())
                        && rightStartDate.getTime() < leftEndDate.getTime())
                        || ((rightStartDate.getTime() > leftStartDate.getTime())
                        && rightStartDate.getTime() < leftEndDate.getTime())) {
                    return true;
                } else {
                    return false;
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return false;
        } else {
            return false;
        }
    }


    public static Boolean checkTimeOverStartTime(String time) {
        if (!"".equals(time)) {
            // 截取逗号前的字符串
            String start = time.substring(0, time.indexOf("-"));
            // 截取逗号后的字符串
            String end = time.substring(start.length() + 1, time.length());
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:ss");
            try {
                Date startDate = simpleDateFormat.parse(start);
                Date endDate = simpleDateFormat.parse(end);
                if (endDate.getTime() <= startDate.getTime()) {
                    return true;
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return false;
        } else {
            return false;
        }
    }

    /**
     * 根据一个字符串日期获取指定日期的起止日期
     */
    public static Map<String, String> getTheStartEndOfAssignDay(String dateTime) throws ParseException {
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        Date date = ft.parse(dateTime);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        String startStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        String endStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
        Map<String, String> map = new HashMap<>();
        map.put("startTime", startStr);
        map.put("endTime", endStr);
        return map;
    }

    public static class IntervalBo {
        private int periodYear;
        private int periodMonth;
        private int periodDay;
        private int periodHour;
        private int periodMinute;
        private int periodSecond;

        public int getPeriodYear() {
            return periodYear;
        }

        public void setPeriodYear(int periodYear) {
            this.periodYear = periodYear;
        }

        public int getPeriodMonth() {
            return periodMonth;
        }

        public void setPeriodMonth(int periodMonth) {
            this.periodMonth = periodMonth;
        }

        public int getPeriodDay() {
            return periodDay;
        }

        public void setPeriodDay(int periodDay) {
            this.periodDay = periodDay;
        }

        public int getPeriodHour() {
            return periodHour;
        }

        public void setPeriodHour(int periodHour) {
            this.periodHour = periodHour;
        }

        public int getPeriodMinute() {
            return periodMinute;
        }

        public void setPeriodMinute(int periodMinute) {
            this.periodMinute = periodMinute;
        }

        public int getPeriodSecond() {
            return periodSecond;
        }

        public void setPeriodSecond(int periodSecond) {
            this.periodSecond = periodSecond;
        }
    }

    /**
     * 日期转换为时间戳
     *
     * @return
     */
    public static Long dateToTime(String dateStr, String formatStr) {
        if (StringUtils.isEmpty(formatStr)) {
            formatStr = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat format = new SimpleDateFormat(formatStr);
        Long time = null;
        try {
            Date date = format.parse(dateStr);
            time = date.getTime();
        } catch (ParseException e) {

            e.printStackTrace();
        }
        return time;
    }

    /**
     * 获取当前时间 分针时间
     *
     * @return
     */
    public static String getNowDateMinuteHand() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("mm");
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }

    /**
     * 获取当前时间到明天0点的秒数
     *
     * @return
     */
    public static long getTomorrowZeroSeconds() {
        long current = System.currentTimeMillis();// 当前时间毫秒数
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        long tomorrowzero = calendar.getTimeInMillis();
        long tomorrowzeroSeconds = (tomorrowzero - current) / 1000;
        return tomorrowzeroSeconds;
    }

    /**
     * 获取今日时间字符串 yyyy-MM-dd HH:mm:ss格式
     *
     * @return
     */
    public static String getNowDateString() {
        return getNowDateWholePoint("yyyy-MM-dd HH:mm:ss");
//        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        LocalDateTime localDateTime = LocalDateTime.now();
//        return dateTimeFormatter.format(localDateTime);
    }

    /**
     * 获取今日时间字符串 yyyy-MM-dd格式
     *
     * @return
     */
    public static String getNowDate() {
        return getNowDateWholePoint("yyyy-MM-dd");
    }

    /**
     * 以指定格式获取当前时间的字符串
     *
     * @param pattern
     * @return
     */
    public static String getNowDateNew(String pattern) {
        // 线程安全的格式化类，不用每次都new个SimpleDateFormat
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        LocalDateTime localDateTime = LocalDateTime.now();
        return dateTimeFormatter.format(localDateTime);
    }

    // 短日期格式
    public static String DATE_FORMAT = "yyyy-MM-dd";

    // 长日期格式
    public static String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";


    /**
     * String类型日期转Long，时间格式为：yyyy-MM-dd HH:mm:ss
     */
    public static Long convertTimeToLong(String time) {
        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(time, ftf);
        return LocalDateTime.from(parse).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
    }

    /**
     * 通过 HH:mm 获取当天完整的 yyyy-MM-dd HH:mm:ss 对应的Long
     */
    public static Long getAllLongDate(String hour) {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(d);
        String dates = format + " " + hour + ":00";
        return convertTimeToLong(dates);
    }

    /**
     * 通过 Long 获取当天完整的 yyyy-MM-dd HH:mm:ss 对应的HH:mm
     */
    public static String getHourDate(Long time) {
        Date d = new Date(time);
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        String format = sdf.format(d);
        return format;
    }


    /**
     * 通过 HH:mm 获取当天与当天零点之差的时间戳值
     */
    public static Long getZeroPointDifferentTime(Long time) {
        Long zeroPointTimestamps = getTodayZeroPointTimestamps(time);
        return time - zeroPointTimestamps;
    }

    /**
     * @Author:Cron
     * @param: time
     * @Description: 获得某天零点时间戳
     */
    public static Long getTodayZeroPointTimestamps(Long time) {
        Long currentTimestamps = time;
        Long oneDayTimestamps = Long.valueOf(60 * 60 * 24 * 1000);
        return currentTimestamps - (currentTimestamps + 60 * 60 * 8 * 1000) % oneDayTimestamps;
    }


    // 获得某天最大时间 2017-10-15 23:59:59
    public static Date getEndOfDay(Date date) {
        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
        ;
        LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX);
        return Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
    }

    // 获得某天最小时间 2017-10-15 00:00:00
    public static Date getStartOfDay(Date date) {
        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
        LocalDateTime startOfDay = localDateTime.with(LocalTime.MIN);
        return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
    }

    /**
     * 将日期格式的字符串转换为长整型
     *
     * @param date
     * @param format
     * @return
     */
    public static long convert2long(String date, String format) {
        try {
            if (!StringUtils.isEmpty(date)) {
                if (StringUtils.isEmpty(format)) format = TIME_FORMAT;
                SimpleDateFormat sf = new SimpleDateFormat(format);
                return sf.parse(date).getTime();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0l;
    }

    /**
     * 将长整型数字转换为日期格式的字符串
     *
     * @param time
     * @param format
     * @return
     */
    public static String convert2String(long time, String format) {
        if (time > 0l) {
            if (StringUtils.isEmpty(format)) format = TIME_FORMAT;
            SimpleDateFormat sf = new SimpleDateFormat(format);
            Date date = new Date(time);
            return sf.format(date);
        }
        return "";
    }

    /**
     * 获取当天0点时间戳(此方法有精度损失问题，上午8点之前的时间计算出来是前一天的时间)
     *
     * @return
     */
    @Deprecated
    public static Long getTodayLongTime() {
        Long current = System.currentTimeMillis();//当前时间毫秒数
        Long zero = current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
        return zero;
    }


    /**
     * 获取昨天0点时间戳
     *
     * @return
     */
    @Deprecated
    public static Long getYesterdayLongTime() {
        Long current = System.currentTimeMillis();//当前时间毫秒数
        Long zero = current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
        return zero - 86400000;
    }

    /**
     * 获取指定年月的第一天
     *
     * @param year
     * @param month
     * @return
     */
    public static String getFirstDayOfMonth(int year, int month) {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR, year);
        //设置月份
        cal.set(Calendar.MONTH, month - 1);
        //获取某月最小天数
        int firstDay = cal.getMinimum(Calendar.DATE);
        //设置日历中月份的最小天数
        cal.set(Calendar.DAY_OF_MONTH, firstDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(cal.getTime());
    }

    /**
     * 获取指定年月的最后一天
     *
     * @param year
     * @param month
     * @return
     */
    public static String getLastDayOfMonth(int year, int month) {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR, year);
        //设置月份
        cal.set(Calendar.MONTH, month - 1);
        //获取某月最大天数
        int lastDay = cal.getActualMaximum(Calendar.DATE);
        //设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, lastDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(cal.getTime());
    }


    public static Long convertTimeToLon1(String time) {
        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        time += " 00:00";
        LocalDateTime parse = LocalDateTime.parse(time, ftf);
        return LocalDateTime.from(parse).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
    }


    public static int getDayByMonth(Long time) {
        Calendar ca = Calendar.getInstance();
        ca.setTimeInMillis(time);
        return ca.get(Calendar.DAY_OF_MONTH);
    }

    /**
     * 获取本周(date为空则为当前周)的最小时间戳(周一零点)
     *
     * @param date
     * @return
     */
    public static Long getMinTimeOfWeek(Date date) {
        if (date == null) {
            date = new Date();
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
        if (dayofweek == 1) {
            dayofweek += 7;
        }
        cal.add(Calendar.DATE, 2 - dayofweek);
        Date monday = cal.getTime();
        return getTodayZeroPointTimestamps(monday.getTime());
    }

    /**
     * 获取本月(date为空则为当前月)的最小时间戳(1日零点)
     *
     * @param date
     * @return
     */
    public static Long getMinTimeOfMonth(Date date) {
        if (date == null) {
            date = new Date();
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH);
        cal.set(year, month, 1, 0, 0, 0);
        return cal.getTimeInMillis() / 1000 * 1000;
    }


    /****-----------------------------------------------------------------------------------------------*/


    /**
     * 判断日期是否合法 默认格式 yyyy-MM-dd
     *
     * @param date 日期
     * @return 是否合法
     * @author yangs
     */
    public static boolean isRightDate(String date) {
        return isRightDate(date, "yyyy-MM-dd");
    }

    /**
     * 判断日期是否合法
     *
     * @param date   日期
     * @param format 格式
     * @return 是否合法
     * @author yangs
     */
    public static boolean isRightDate(String date, String format) {
        try {
            LocalDate.parse(date, DateTimeFormatter.ofPattern(format));
        } catch (Exception e) {
            //log.info("{}  时间格式不符合 {}", date, format);
            return false;
        }
        return true;
    }

    /**
     * 当天日期 yyyy-MM-dd
     *
     * @return 当天日期
     * @author yangs
     */
    public static String nowDate() {
        return LocalDate.now().toString();
    }

    /**
     * 当前时间戳 毫秒
     *
     * @return 当前时间戳 毫秒
     * @author yangs
     */
    public static long nowEpochMilli() {
        return LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    /**
     * 当前时间戳 秒
     *
     * @return
     */
    public static long nowSecondMolli() {
        return System.currentTimeMillis() / 1000;
    }

    /**
     * 时间戳 转日期字符串 yyyy-MM-dd HH:mm:ss
     *
     * @param time
     * @author yangs
     */
    public static String long2String(long time) {
        return long2StringMilli(time, "yyyy-MM-dd HH:mm:ss");
    }

    /**
     * 时间戳 转日期字符串
     *
     * @param time   秒
     * @param format 格式
     * @author yangs
     */
    public static String long2String(long time, String format) {
        LocalDateTime time1 = LocalDateTime.ofEpochSecond(time, 0, ZoneOffset.ofHours(8));
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        return time1.format(formatter);
    }


    /**
     * 时间戳（毫秒） 转日期字符串
     *
     * @param time   毫秒
     * @param format 格式
     * @author yangs
     */
    public static String long2StringMilli(long time, String format) {
        LocalDateTime time1 = long2LocalDateTime(time);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        return time1.format(formatter);
    }

    /**
     * 时间戳转LocalDateTime
     *
     * @param time(毫秒时间戳)
     */
    public static LocalDateTime long2LocalDateTime(long time) {
        LocalDateTime time1 = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.ofHours(8));
        return time1;
    }

    /**
     * 时间字符串 转 时间戳（毫秒） 默认ISO-8601格式 yyyy-MM-ddTHH:MM:ss(如 2018-11-08T00:00:00)
     *
     * @param time 时间
     * @author yangs
     */
    public static long string2Long(String time) {
        return string2Long(time, null);
    }

    /**
     * 时间字符串 转 时间戳（毫秒）
     *
     * @param time   时间
     * @param format 格式
     * @return
     * @author yangs
     */
    public static long string2Long(String time, String format) {
        if (null == format || "".equals(format)) {
            return localDateTime2Long(LocalDateTime.parse(time));
        } else {
            return localDateTime2Long(LocalDateTime.parse(time, DateTimeFormatter.ofPattern(format)));
        }

    }

    /**
     * 转 时间戳（毫秒）
     *
     * @param time
     * @author yangs
     */
    public static long localDateTime2Long(LocalDateTime time) {
        return time.toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    /**
     * 获取某天的 开始时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfDay(String date) {
        return getStartOfDay(LocalDate.parse(date));
    }

    /**
     * 获取某天的 开始时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfDay(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date, LocalTime.MIN));
    }

    /**
     * 获取某天 结束的时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfDay(String date) {
        return getEndOfDay(LocalDate.parse(date));
    }

    /**
     * 获取某天 结束的时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfDay(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date, LocalTime.MAX));
    }

    /**
     * 获取某个周第一天 时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfWeek(String date) {
        return getStartOfWeek(LocalDate.parse(date));
    }

    /**
     * 获取某个周第一天 时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfWeek(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(DayOfWeek.MONDAY), LocalTime.MIN));
    }

    /**
     * 获取某个周最后一天时间戳 (毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfWeek(String date) {
        return getEndOfWeek(LocalDate.parse(date));
    }

    /**
     * 获取某个周最后一天时间戳 (毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfWeek(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(DayOfWeek.SUNDAY), LocalTime.MAX));
    }

    /**
     * 获取某月 第一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfMonth(String date) {
        return getStartOfMonth(LocalDate.parse(date));
    }

    /**
     * 获取某月 第一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfMonth(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(TemporalAdjusters.firstDayOfMonth()), LocalTime.MIN));
    }

    /**
     * 获取某月 最后一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfMonth(String date) {
        return getEndOfMonth(LocalDate.parse(date));
    }

    /**
     * 获取某月 最后一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfMonth(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX));
    }


    /**
     * 获取某年 第一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfYear(String date) {
        return getStartOfYear(LocalDate.parse(date));
    }

    /**
     * 获取某年 第一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getStartOfYear(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN));
    }

    /**
     * 获取某年 最后一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfYear(String date) {
        return getEndOfYear(LocalDate.parse(date));
    }

    /**
     * 获取某年 最后一天时间戳(毫秒）
     *
     * @param date yyyy-MM-dd
     * @author yangs
     */
    public static long getEndOfYear(LocalDate date) {
        return localDateTime2Long(LocalDateTime.of(date.with(TemporalAdjusters.lastDayOfYear()), LocalTime.MAX));
    }

    /**
     * 获取星期数值(1,2,3,4,5,6,7)
     *
     * @param timeStamp 为空则为当前时间
     * @return 获取星期数值(1, 2, 3, 4, 5, 6, 7)
     */
    public static int getDayOfWeek(Long timeStamp) {
        LocalDate localDate = null;
        if (null == timeStamp || timeStamp <= 0) {
            localDate = LocalDate.now();
        } else {
            Instant instant = new Date(timeStamp).toInstant();
            ZoneId zoneId = ZoneId.systemDefault();
            // atZone()方法返回在指定时区从此instant生成的ZonedDateTime。
            localDate = instant.atZone(zoneId).toLocalDate();
        }
        return localDate.getDayOfWeek().getValue();
    }

    /**
     * 获取前n个工作日的日期
     *
     * @param workDayNum
     * @return 获取前n个工作日的日期
     */
    public static List<String> getWorkDay(int workDayNum) {
        List<String> workDays = new ArrayList<>();
        LocalDate date = LocalDate.now();
        for (int i = 0; i < workDayNum; i++) {
            date = date.minusDays(1);
            int week = date.getDayOfWeek().getValue();
            if (week == 6 || week == 7) {
                workDayNum++;
            } else {
                workDays.add(date.toString());
            }
        }
        return workDays;
    }

    /**
     * 时间戳 转日期字符串 yyyy-MM
     *
     * @param time
     * @author pjh
     */
    public static String long2StringToYYMM(long time) {
        return long2StringMilli(time, "yyyy-MM");
    }

    /**
     * 获取过去第几天的日期
     *
     * @param past
     * @return
     */
    public static String getPastDate(int past) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
        Date today = calendar.getTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String result = format.format(today);
        return result;
    }

    /**
     * 获取多少天以前的日期（时间戳）
     *
     * @param day
     * @return
     * @Author : Administrator. create at 2020年2月27日 下午2:58:33
     */
    public static Long beforeTime(int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - day);
        return calendar.getTimeInMillis();
    }

    public static String getSysYear() {
        Calendar date = Calendar.getInstance();
        String year = String.valueOf(date.get(Calendar.YEAR));
        return year;
    }

    @SneakyThrows
    public static void main(String[] args) {
//        System.out.println(getWorkDay(10));
//        long a = 1542327600000l, b = 1542330300000l; //2018-11-16 8:20:00,2018-11-16 9:05:00
//        long d = (b-a)/1000/60;
//        int groupNum = new BigDecimal(String.valueOf(d)).divide(new BigDecimal(2),0, BigDecimal.ROUND_UP).intValue();
//        System.out.println(groupNum);
        // System.out.println(yesterDate());

//        String y = "2018";
//        System.out.println(getStartOfMonth(y+"-01-01"));
//        System.out.println(getEndOfMonth(y+"-12-31"));
//        System.out.println(getStartOfDay("2018-12-25"));

        //System.out.println(isRightDate("2018-01-01", "yyyy-MM-dd"));
//        System.out.println(DateUtil.nowDate().substring(5));
//        System.out.println(DateUtil.getPastDate(1).substring(5));
//        System.out.println(getSysYear());
//        String a = "1|2|3";
//        String[] as = a.split("\\|");
//        for (String e:as) {
//            System.out.println(e);
//        }
//        long curSysTime = System.currentTimeMillis();
//        System.out.println(curSysTime);
//        System.out.println(new Date(curSysTime));
//
//        long deadtime=curSysTime-1*1000L;
//        System.out.println(deadtime);
//        System.out.println(new Date(deadtime));

//        Date da = parseDate(getNowDateString(), "yyyyMMddHHmmSS");
//
        String nowDateWholePoint = getNowDate();
        String nowDateString = getNowDateString();
        System.out.println(nowDateWholePoint);
    }

}
